package com.smedi.ismedi.web.starter.thread;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class BaseThreadPool extends ThreadPoolExecutor {
    private static final int cpu = Runtime.getRuntime().availableProcessors();
    private static final int DEFAULT_CORE_POOL_SIZE = 2 * cpu + 1;
    private static final int MAXIMUM_POOL_SIZE = 2 * cpu + 1;
    private static final int KEEP_ALIVE_TIME = 1200;
    private static final TimeUnit DEFAULT_UNIT = TimeUnit.SECONDS;
    private static final BlockingQueue<Runnable> DEFAULT_WORK_QUEUE = new LinkedBlockingQueue<>(1024);

    public BaseThreadPool() {
        super(DEFAULT_CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE_TIME, DEFAULT_UNIT, DEFAULT_WORK_QUEUE);
    }
}
